/*******************************************************************
 * author   :  Charlies-ls
 * Date     :  2021-09-26
 * Function :  safe fifo
 * Copyright (c) 2021. artestplay@outlook.com. All Rights Reserved.
 *******************************************************************/

#ifndef AX_THREAD_fifo__h
#define AX_THREAD_fifo__h
#include "ax_fifo.h"
#include "ax_thread.h"
typedef struct
{
   ax_fifo*     fifo;
   ax_mutex_t*  mutex;
   ax_cond_t*   write_signal;
   ax_cond_t*   read_signal;
}ax_thread_fifo;
#ifdef __cplusplus
extern "C"
{
#endif

ax_thread_fifo* ax_thread_fifo_create(); 
void    ax_thread_fifo_destory(ax_thread_fifo*q);
void    ax_thread_fifo_write(ax_thread_fifo*queue,void* data);
void*   ax_thread_fifo_read(ax_thread_fifo*queue);
void*   ax_thread_fifo_front(ax_thread_fifo*queue);
void*   ax_thread_fifo_read_noblock(ax_thread_fifo*queue);
void*   ax_thread_fifo_read_timeout(ax_thread_fifo*queue,int timeout);
int     ax_thread_fifo_size(ax_thread_fifo*fifo);
#ifdef __cplusplus
}
#endif

#endif
